/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication20;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;


public class ServidorHilo extends Thread {

    private Socket socket;
    private DataOutputStream dos;
    private DataInputStream dis;

    public ServidorHilo(Socket socket) {
        this.socket = socket;
        try {
            dos = new DataOutputStream(socket.getOutputStream());
            dis = new DataInputStream(socket.getInputStream());
        } catch (IOException ex) {
            Logger.getLogger(ServidorHilo.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void desconnectar() {
        try {
            socket.close();
        } catch (IOException ex) {
            Logger.getLogger(ServidorHilo.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    public void run() {
        String accion;
        int xrojo;
        int yrojo;
        try {
//            String color="";
//            if(color.equals("Azul")){
//            dos.writeBoolean(false);
//            }
//            if(color.equals("Rojo")){
//            dos.writeBoolean(false);  
//            }
//            if(color.equals("Amarillo")){
//            dos.writeBoolean(false); 
//            }
//            if(color.equals("Verde")){
//            dos.writeBoolean(false); 
//            }
            accion = dis.readUTF();
            System.out.println("El cliente "+accion+" saluda");
            dos.writeUTF("adios");
            xrojo = dis.readInt();
            yrojo = dis.readInt();
            dos.writeInt(xrojo);
            dos.writeInt(yrojo);
            
            

        } catch (IOException ex) {
            Logger.getLogger(ServidorHilo.class.getName()).log(Level.SEVERE, null, ex);
        }



        desconnectar();
    }
    

}